summaryrefslogtreecommitdiff
path: root/ui/routes/(login)/invite/[invite]/+page.svelte
blob: 8f4d1a4b87a66dba65be07e066bb4c4b75763a13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<script>
	import { goto } from '$app/navigation';
	import { acceptInvite } from '$lib/apiServer';

	import LogIn from '$lib/components/LogIn.svelte';

	export let data;

	let username = '',
		password = '';
	let pending = false;
	$: disabled = pending;

	async function onSubmit() {
		pending = true;
		const response = await acceptInvite(data.invite.id, username, password);
		if (200 <= response.status && response.status < 300) {
			username = '';
			password = '';
			goto('/');
		}
		pending = false;
	}
</script>

{#await data}
	<div class="card m-4 p-4">
		<p>Loading invitation…</p>
	</div>
{:then { invite }}
	<div class="card m-4 p-4">
		<p>Hi there! {invite.issuer} invites you to the conversation.</p>
	</div>
	<LogIn bind:disabled bind:username bind:password on:submit={onSubmit} />
{/await}